package com.maxd.model;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 积分流水表
 */
@Entity
@Getter
@Setter
@ToString
@SuperBuilder
@NoArgsConstructor
@DynamicInsert
@DynamicUpdate
@ApiModel("积分流水表")
@Table(name = "point_record")
public class PointRecord implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @ApiModelProperty("积分流水号，系统产生")
    @Column(name = "seq_no", nullable = false)
    private String seqNo;

    @ApiModelProperty("GEN-产生流水 USE-消耗流水")
    @Column(name = "record_type", nullable = false)
    private String recordType;

    @ApiModelProperty("积分数，产生积分为正数，使用积分为负数")
    @Column(name = "point_amount", nullable = false)
    private BigDecimal pointAmount;

    @ApiModelProperty("用户id")
    @Column(name = "user_id", nullable = false)
    private Long userId;

    @Column(name = "sub_user_id")
    @ApiModelProperty("下级用户ID，如积分是下级购买商品获取则有值")
    private Long subUserId;

    @Column(name = "sub_user_phone")
    @ApiModelProperty("下级用户手机号，如积分是下级购买商品获取则有值")
    private String subUserPhone;

    @Column(name = "scene_code", nullable = false)
    @ApiModelProperty("场景编码 GEN_BUY-买入商品获取积分  GEN_SUB_BUY-下级购买商品 USE_BUY-购买商品使用积分")
    private String sceneCode;

    @Column(name = "business_id")
    @ApiModelProperty("业务流水号，通过场景编码和业务主键能定位到具体的业务交易流水")
    private String businessId;

    @Column(name = "item_id")
    @ApiModelProperty("购买的对象，可能是一个商品ID、活动ID等")
    private String itemId;

    @Column(name = "item_name")
    @ApiModelProperty("购买的对象名称")
    private String itemName;

    @ApiModelProperty("备注")
    @Column(name = "remark")
    private String remark;

    @ApiModelProperty("创建时间")
    @Column(name = "create_time", nullable = false)
    private Date createTime;

    @ApiModelProperty("更新时间")
    @Column(name = "update_time", nullable = false)
    private Date updateTime;

    @ApiModelProperty("创建人")
    @Column(name = "create_by")
    private String createBy;

    @ApiModelProperty("更新人")
    @Column(name = "update_by")
    private String updateBy;

}
